home *** CD-ROM | disk | FTP | other *** search
/ Professional Soft Collection 1.02 / Professional Soft Collection 1.02.iso / msdos622.rus / msdos_4.ddi / NIBBLES.BAS < prev    next >
BASIC Source File  |  1993-05-31  |  24KB  |  722 lines

  1. '
  2. '                         Q B a s i c   N i b b l e s
  3. '
  4. '                   Copyright (C) Microsoft Corporation 1990
  5. '
  6. ' Nibbles is a game for one or two players.  Navigate your snakes
  7. ' around the game board trying to eat up numbers while avoiding
  8. ' running into walls or other snakes.  The more numbers you eat up,
  9. ' the more points you gain and the longer your snake becomes.
  10. '
  11. ' To run this game, press Shift+F5.
  12. '
  13. ' To exit QBasic, press Alt, F, X.
  14. '
  15. ' To get help on a BASIC keyword, move the cursor to the keyword and press
  16. ' F1 or click the right mouse button.
  17. '
  18.  
  19. 'Set default data type to integer for faster game play
  20. DEFINT A-Z
  21.  
  22. 'User-defined TYPEs
  23. TYPE snakeBody
  24.     row AS INTEGER
  25.     col AS INTEGER
  26. END TYPE
  27.  
  28. 'This type defines the player's snake
  29. TYPE snaketype
  30.     head      AS INTEGER
  31.     length    AS INTEGER
  32.     row       AS INTEGER
  33.     col       AS INTEGER
  34.     direction AS INTEGER
  35.     lives     AS INTEGER
  36.     score     AS INTEGER
  37.     scolor    AS INTEGER
  38.     alive     AS INTEGER
  39. END TYPE
  40.  
  41. 'This type is used to represent the playing screen in memory
  42. 'It is used to simulate graphics in text mode, and has some interesting,
  43. 'and slightly advanced methods to increasing the speed of operation.
  44. 'Instead of the normal 80x25 text graphics using chr$(219) "█", we will be
  45. 'using chr$(220)"▄" and chr$(223) "▀" and chr$(219) "█" to mimic an 80x50
  46. 'pixel screen.
  47. 'Check out sub-programs SET and POINTISTHERE to see how this is implemented
  48. 'feel free to copy these (as well as arenaType and the DIM ARENA stmt and the
  49. 'initialization code in the DrawScreen subprogram) and use them in your own
  50. 'programs
  51. TYPE arenaType
  52.     realRow     AS INTEGER        'Maps the 80x50 point into the real 80x25
  53.     acolor      AS INTEGER        'Stores the current color of the point
  54.     sister      AS INTEGER        'Each char has 2 points in it.  .SISTER is
  55. END TYPE                          '-1 if sister point is above, +1 if below
  56.  
  57. 'Sub Declarations
  58. DECLARE SUB SpacePause (text$)
  59. DECLARE SUB PrintScore (NumPlayers%, score1%, score2%, lives1%, lives2%)
  60. DECLARE SUB Intro ()
  61. DECLARE SUB GetInputs (NumPlayers, speed, diff$, monitor$)
  62. DECLARE SUB DrawScreen ()
  63. DECLARE SUB PlayNibbles (NumPlayers, speed, diff$)
  64. DECLARE SUB Set (row, col, acolor)
  65. DECLARE SUB Center (row, text$)
  66. DECLARE SUB DoIntro ()
  67. DECLARE SUB Initialize ()
  68. DECLARE SUB SparklePause ()
  69. DECLARE SUB Level (WhatToDO, sammy() AS snaketype)
  70. DECLARE SUB InitColors ()
  71. DECLARE SUB EraseSnake (snake() AS ANY, snakeBod() AS ANY, snakeNum%)
  72. DECLARE FUNCTION StillWantsToPlay ()
  73. DECLARE FUNCTION PointIsThere (row, col, backColor)
  74.  
  75. 'Constants
  76. CONST TRUE = -1
  77. CONST FALSE = NOT TRUE
  78. CONST MAXSNAKELENGTH = 1000
  79. CONST STARTOVER = 1             ' Parameters to 'Level' SUB
  80. CONST SAMELEVEL = 2
  81. CONST NEXTLEVEL = 3
  82.  
  83. 'Global Variables
  84. DIM SHARED arena(1 TO 50, 1 TO 80) AS arenaType
  85. DIM SHARED curLevel, colorTable(10)
  86.  
  87.     RANDOMIZE TIMER
  88.     GOSUB ClearKeyLocks
  89.     Intro
  90.     GetInputs NumPlayers, speed, diff$, monitor$
  91.     GOSUB SetColors
  92.     DrawScreen
  93.  
  94.     DO
  95.       PlayNibbles NumPlayers, speed, diff$
  96.     LOOP WHILE StillWantsToPlay
  97.  
  98.     GOSUB RestoreKeyLocks
  99.     COLOR 15, 0
  100.     CLS
  101. END
  102.  
  103. ClearKeyLocks:
  104.     DEF SEG = 0                     ' Turn off CapLock, NumLock and ScrollLock
  105.     KeyFlags = PEEK(1047)
  106.     POKE 1047, &H0
  107.     DEF SEG
  108.     RETURN
  109.  
  110. RestoreKeyLocks:
  111.     DEF SEG = 0                     ' Restore CapLock, NumLock and ScrollLock states
  112.     POKE 1047, KeyFlags
  113.     DEF SEG
  114.     RETURN
  115.  
  116. SetColors:
  117.     IF monitor$ = "M" THEN
  118.         RESTORE mono
  119.     ELSE
  120.         RESTORE normal
  121.     END IF
  122.  
  123.     FOR a = 1 TO 6
  124.         READ colorTable(a)
  125.     NEXT a
  126.     RETURN
  127.  
  128.            'snake1     snake2   Walls  Background  Dialogs-Fore  Back
  129. mono:   DATA 15,         7,       7,     0,          15,            0
  130. normal: DATA 14,         13,      12,    1,          15,            4
  131. END
  132.  
  133. 'Center:
  134. '  Centers text on given row
  135. SUB Center (row, text$)
  136.     LOCATE row, 41 - LEN(text$) / 2
  137.     PRINT text$;
  138. END SUB
  139.  
  140. 'DrawScreen:
  141. '  Draws playing field
  142. SUB DrawScreen
  143.  
  144.     'initialize screen
  145.     VIEW PRINT
  146.     COLOR colorTable(1), colorTable(4)
  147.     CLS
  148.  
  149.     'Print title & message
  150.     Center 1, "Nibbles!"
  151.     Center 11, "Initializing Playing Field..."
  152.     
  153.     'Initialize arena array
  154.     FOR row = 1 TO 50
  155.         FOR col = 1 TO 80
  156.             arena(row, col).realRow = INT((row + 1) / 2)
  157.             arena(row, col).sister = (row MOD 2) * 2 - 1
  158.         NEXT col
  159.     NEXT row
  160. END SUB
  161.  
  162. 'EraseSnake:
  163. '  Erases snake to facilitate moving through playing field
  164. SUB EraseSnake (snake() AS snaketype, snakeBod() AS snakeBody, snakeNum)
  165.  
  166.     FOR c = 0 TO 9
  167.         FOR b = snake(snakeNum).length - c TO 0 STEP -10
  168.             tail = (snake(snakeNum).head + MAXSNAKELENGTH - b) MOD MAXSNAKELENGTH
  169.             Set snakeBod(tail, snakeNum).row, snakeBod(tail, snakeNum).col, colorTable(4)
  170.         NEXT b
  171.     NEXT c
  172.     
  173. END SUB
  174.  
  175. 'GetInputs:
  176. '  Gets player inputs
  177. SUB GetInputs (NumPlayers, speed, diff$, monitor$)
  178.  
  179.     COLOR 7, 0
  180.     CLS
  181.  
  182.     DO
  183.         LOCATE 5, 47: PRINT SPACE$(34);
  184.         LOCATE 5, 20
  185.         INPUT "How many players (1 or 2)"; num$
  186.     LOOP UNTIL VAL(num$) = 1 OR VAL(num$) = 2
  187.     NumPlayers = VAL(num$)
  188.  
  189.     LOCATE 8, 21: PRINT "Skill level (1 to 100)"
  190.     LOCATE 9, 22: PRINT "1   = Novice"
  191.     LOCATE 10, 22: PRINT "90  = Expert"
  192.     LOCATE 11, 22: PRINT "100 = Twiddle Fingers"
  193.     LOCATE 12, 15: PRINT "(Computer speed may affect your skill level)"
  194.     DO
  195.         LOCATE 8, 44: PRINT SPACE$(35);
  196.         LOCATE 8, 43
  197.         INPUT gamespeed$
  198.     LOOP UNTIL VAL(gamespeed$) >= 1 AND VAL(gamespeed$) <= 100
  199.     speed = VAL(gamespeed$)
  200.   
  201.     speed = (100 - speed) * 2 + 1
  202.  
  203.     DO
  204.         LOCATE 15, 56: PRINT SPACE$(25);
  205.         LOCATE 15, 15
  206.         INPUT "Increase game speed during play (Y or N)"; diff$
  207.         diff$ = UCASE$(diff$)
  208.     LOOP UNTIL diff$ = "Y" OR diff$ = "N"
  209.  
  210.     DO
  211.         LOCATE 17, 46: PRINT SPACE$(34);
  212.         LOCATE 17, 17
  213.         INPUT "Monochrome or color monitor (M or C)"; monitor$
  214.         monitor$ = UCASE$(monitor$)
  215.     LOOP UNTIL monitor$ = "M" OR monitor$ = "C"
  216.  
  217.     startTime# = TIMER                          ' Calculate speed of system
  218.     FOR i# = 1 TO 1000: NEXT i#                 ' and do some compensation
  219.     stopTime# = TIMER
  220.     speed = speed * .5 / (stopTime# - startTime#)
  221.  
  222. END SUB
  223.  
  224. 'InitColors:
  225. 'Initializes playing field colors
  226. SUB InitColors
  227.     
  228.     FOR row = 1 TO 50
  229.         FOR col = 1 TO 80
  230.             arena(row, col).acolor = colorTable(4)
  231.         NEXT col
  232.     NEXT row
  233.  
  234.     CLS
  235.    
  236.     'Set (turn on) pixels for screen border
  237.     FOR col = 1 TO 80
  238.         Set 3, col, colorTable(3)
  239.         Set 50, col, colorTable(3)
  240.     NEXT col
  241.  
  242.     FOR row = 4 TO 49
  243.         Set row, 1, colorTable(3)
  244.         Set row, 80, colorTable(3)
  245.     NEXT row
  246.  
  247. END SUB
  248.  
  249. 'Intro:
  250. '  Displays game introduction
  251. SUB Intro
  252.     SCREEN 0
  253.     WIDTH 80, 25
  254.     COLOR 15, 0
  255.     CLS
  256.  
  257.     Center 4, "Q B a s i c   N i b b l e s"
  258.     COLOR 7
  259.     Center 6, "Copyright (C) Microsoft Corporation 1990"
  260.     Center 8, "Nibbles is a game for one or two players.  Navigate your snakes"
  261.     Center 9, "around the game board trying to eat up numbers while avoiding"
  262.     Center 10, "running into walls or other snakes.  The more numbers you eat up,"
  263.     Center 11, "the more points you gain and the longer your snake becomes."
  264.     Center 13, " Game Controls "
  265.     Center 15, "  General             Player 1               Player 2    "
  266.     Center 16, "                        (Up)                   (Up)      "
  267.     Center 17, "P - Pause                " + CHR$(24) + "                      W       "
  268.     Center 18, "                     (Left) " + CHR$(27) + "   " + CHR$(26) + " (Right)   (Left) A   D (Right)  "
  269.     Center 19, "                         " + CHR$(25) + "                      S       "
  270.     Center 20, "                       (Down)                 (Down)     "
  271.     Center 24, "Press any key to continue"
  272.  
  273.     PLAY "MBT160O1L8CDEDCDL4ECC"
  274.     SparklePause
  275.  
  276. END SUB
  277.  
  278. 'Level:
  279. 'Sets game level
  280. SUB Level (WhatToDO, sammy() AS snaketype) STATIC
  281.     
  282.     SELECT CASE (WhatToDO)
  283.  
  284.     CASE STARTOVER
  285.         curLevel = 1
  286.     CASE NEXTLEVEL
  287.         curLevel = curLevel + 1
  288.     END SELECT
  289.  
  290.     sammy(1).head = 1                       'Initialize Snakes
  291.     sammy(1).length = 2
  292.     sammy(1).alive = TRUE
  293.     sammy(2).head = 1
  294.     sammy(2).length = 2
  295.     sammy(2).alive = TRUE
  296.  
  297.     InitColors
  298.     
  299.     SELECT CASE curLevel
  300.     CASE 1
  301.         sammy(1).row = 25: sammy(2).row = 25
  302.         sammy(1).col = 50: sammy(2).col = 30
  303.         sammy(1).direction = 4: sammy(2).direction = 3
  304.  
  305.  
  306.     CASE 2
  307.         FOR i = 20 TO 60
  308.             Set 25, i, colorTable(3)
  309.         NEXT i
  310.         sammy(1).row = 7: sammy(2).row = 43
  311.         sammy(1).col = 60: sammy(2).col = 20
  312.         sammy(1).direction = 3: sammy(2).direction = 4
  313.  
  314.     CASE 3
  315.         FOR i = 10 TO 40
  316.             Set i, 20, colorTable(3)
  317.             Set i, 60, colorTable(3)
  318.         NEXT i
  319.         sammy(1).row = 25: sammy(2).row = 25
  320.         sammy(1).col = 50: sammy(2).col = 30
  321.         sammy(1).direction = 1: sammy(2).direction = 2
  322.  
  323.     CASE 4
  324.         FOR i = 4 TO 30
  325.             Set i, 20, colorTable(3)
  326.             Set 53 - i, 60, colorTable(3)
  327.         NEXT i
  328.         FOR i = 2 TO 40
  329.             Set 38, i, colorTable(3)
  330.             Set 15, 81 - i, colorTable(3)
  331.         NEXT i
  332.         sammy(1).row = 7: sammy(2).row = 43
  333.         sammy(1).col = 60: sammy(2).col = 20
  334.         sammy(1).direction = 3: sammy(2).direction = 4
  335.    
  336.     CASE 5
  337.         FOR i = 13 TO 39
  338.             Set i, 21, colorTable(3)
  339.             Set i, 59, colorTable(3)
  340.         NEXT i
  341.         FOR i = 23 TO 57
  342.             Set 11, i, colorTable(3)
  343.             Set 41, i, colorTable(3)
  344.         NEXT i
  345.         sammy(1).row = 25: sammy(2).row = 25
  346.         sammy(1).col = 50: sammy(2).col = 30
  347.         sammy(1).direction = 1: sammy(2).direction = 2
  348.  
  349.     CASE 6
  350.         FOR i = 4 TO 49
  351.             IF i > 30 OR i < 23 THEN
  352.                 Set i, 10, colorTable(3)
  353.                 Set i, 20, colorTable(3)
  354.                 Set i, 30, colorTable(3)
  355.                 Set i, 40, colorTable(3)
  356.                 Set i, 50, colorTable(3)
  357.                 Set i, 60, colorTable(3)
  358.                 Set i, 70, colorTable(3)
  359.             END IF
  360.         NEXT i
  361.         sammy(1).row = 7: sammy(2).row = 43
  362.         sammy(1).col = 65: sammy(2).col = 15
  363.         sammy(1).direction = 2: sammy(2).direction = 1
  364.  
  365.     CASE 7
  366.         FOR i = 4 TO 49 STEP 2
  367.             Set i, 40, colorTable(3)
  368.         NEXT i
  369.         sammy(1).row = 7: sammy(2).row = 43
  370.         sammy(1).col = 65: sammy(2).col = 15
  371.         sammy(1).direction = 2: sammy(2).direction = 1
  372.  
  373.     CASE 8
  374.         FOR i = 4 TO 40
  375.             Set i, 10, colorTable(3)
  376.             Set 53 - i, 20, colorTable(3)
  377.             Set i, 30, colorTable(3)
  378.             Set 53 - i, 40, colorTable(3)
  379.             Set i, 50, colorTable(3)
  380.             Set 53 - i, 60, colorTable(3)
  381.             Set i, 70, colorTable(3)
  382.         NEXT i
  383.         sammy(1).row = 7: sammy(2).row = 43
  384.         sammy(1).col = 65: sammy(2).col = 15
  385.         sammy(1).direction = 2: sammy(2).direction = 1
  386.  
  387.     CASE 9
  388.         FOR i = 6 TO 47
  389.             Set i, i, colorTable(3)
  390.             Set i, i + 28, colorTable(3)
  391.         NEXT i
  392.         sammy(1).row = 40: sammy(2).row = 15
  393.         sammy(1).col = 75: sammy(2).col = 5
  394.         sammy(1).direction = 1: sammy(2).direction = 2
  395.    
  396.     CASE ELSE
  397.         FOR i = 4 TO 49 STEP 2
  398.             Set i, 10, colorTable(3)
  399.             Set i + 1, 20, colorTable(3)
  400.             Set i, 30, colorTable(3)
  401.             Set i + 1, 40, colorTable(3)
  402.             Set i, 50, colorTable(3)
  403.             Set i + 1, 60, colorTable(3)
  404.             Set i, 70, colorTable(3)
  405.         NEXT i
  406.         sammy(1).row = 7: sammy(2).row = 43
  407.         sammy(1).col = 65: sammy(2).col = 15
  408.         sammy(1).direction = 2: sammy(2).direction = 1
  409.  
  410.     END SELECT
  411. END SUB
  412.  
  413. 'PlayNibbles:
  414. '  Main routine that controls game play
  415. SUB PlayNibbles (NumPlayers, speed, diff$)
  416.  
  417.     'Initialize Snakes
  418.     DIM sammyBody(MAXSNAKELENGTH - 1, 1 TO 2) AS snakeBody
  419.     DIM sammy(1 TO 2) AS snaketype
  420.     sammy(1).lives = 5
  421.     sammy(1).score = 0
  422.     sammy(1).scolor = colorTable(1)
  423.     sammy(2).lives = 5
  424.     sammy(2).score = 0
  425.     sammy(2).scolor = colorTable(2)
  426.                  
  427.     Level STARTOVER, sammy()
  428.     startRow1 = sammy(1).row: startCol1 = sammy(1).col
  429.     startRow2 = sammy(2).row: startCol2 = sammy(2).col
  430.  
  431.     curSpeed = speed
  432.  
  433.     'play Nibbles until finished
  434.  
  435.     SpacePause "     Level" + STR$(curLevel) + ",  Push Space"
  436.     gameOver = FALSE
  437.     DO
  438.         IF NumPlayers = 1 THEN
  439.             sammy(2).row = 0
  440.         END IF
  441.  
  442.         number = 1          'Current number that snakes are trying to run into
  443.         nonum = TRUE        'nonum = TRUE if a number is not on the screen
  444.  
  445.         playerDied = FALSE
  446.         PrintScore NumPlayers, sammy(1).score, sammy(2).score, sammy(1).lives, sammy(2).lives
  447.         PLAY "T160O1>L20CDEDCDL10ECC"
  448.  
  449.         DO
  450.             'Print number if no number exists
  451.             IF nonum = TRUE THEN
  452.                 DO
  453.                     numberRow = INT(RND(1) * 47 + 3)
  454.                     NumberCol = INT(RND(1) * 78 + 2)
  455.                     sisterRow = numberRow + arena(numberRow, NumberCol).sister
  456.                 LOOP UNTIL NOT PointIsThere(numberRow, NumberCol, colorTable(4)) AND NOT PointIsThere(sisterRow, NumberCol, colorTable(4))
  457.                 numberRow = arena(numberRow, NumberCol).realRow
  458.                 nonum = FALSE
  459.                 COLOR colorTable(1), colorTable(4)
  460.                 LOCATE numberRow, NumberCol
  461.                 PRINT RIGHT$(STR$(number), 1);
  462.                 count = 0
  463.             END IF
  464.  
  465.             'Delay game
  466.             FOR a# = 1 TO curSpeed:  NEXT a#
  467.  
  468.             'Get keyboard input & Change direction accordingly
  469.             kbd$ = INKEY$
  470.             SELECT CASE kbd$
  471.                 CASE "w", "W": IF sammy(2).direction <> 2 THEN sammy(2).direction = 1
  472.                 CASE "s", "S": IF sammy(2).direction <> 1 THEN sammy(2).direction = 2
  473.                 CASE "a", "A": IF sammy(2).direction <> 4 THEN sammy(2).direction = 3
  474.                 CASE "d", "D": IF sammy(2).direction <> 3 THEN sammy(2).direction = 4
  475.                 CASE CHR$(0) + "H": IF sammy(1).direction <> 2 THEN sammy(1).direction = 1
  476.                 CASE CHR$(0) + "P": IF sammy(1).direction <> 1 THEN sammy(1).direction = 2
  477.                 CASE CHR$(0) + "K": IF sammy(1).direction <> 4 THEN sammy(1).direction = 3
  478.                 CASE CHR$(0) + "M": IF sammy(1).direction <> 3 THEN sammy(1).direction = 4
  479.                 CASE "p", "P": SpacePause " Game Paused ... Push Space  "
  480.                 CASE ELSE
  481.             END SELECT
  482.  
  483.             FOR a = 1 TO NumPlayers
  484.                 'Move Snake
  485.                 SELECT CASE sammy(a).direction
  486.                     CASE 1: sammy(a).row = sammy(a).row - 1
  487.                     CASE 2: sammy(a).row = sammy(a).row + 1
  488.                     CASE 3: sammy(a).col = sammy(a).col - 1
  489.                     CASE 4: sammy(a).col = sammy(a).col + 1
  490.                 END SELECT
  491.  
  492.                 'If snake hits number, respond accordingly
  493.                 IF numberRow = INT((sammy(a).row + 1) / 2) AND NumberCol = sammy(a).col THEN
  494.                     PLAY "MBO0L16>CCCE"
  495.                     IF sammy(a).length < (MAXSNAKELENGTH - 30) THEN
  496.                         sammy(a).length = sammy(a).length + number * 4
  497.                     END IF
  498.                     sammy(a).score = sammy(a).score + number
  499.                     PrintScore NumPlayers, sammy(1).score, sammy(2).score, sammy(1).lives, sammy(2).lives
  500.                     number = number + 1
  501.                     IF number = 10 THEN
  502.                         EraseSnake sammy(), sammyBody(), 1
  503.                         EraseSnake sammy(), sammyBody(), 2
  504.                         LOCATE numberRow, NumberCol: PRINT " "
  505.                         Level NEXTLEVEL, sammy()
  506.                         PrintScore NumPlayers, sammy(1).score, sammy(2).score, sammy(1).lives, sammy(2).lives
  507.                         SpacePause "     Level" + STR$(curLevel) + ",  Push Space"
  508.                         IF NumPlayers = 1 THEN sammy(2).row = 0
  509.                         number = 1
  510.                         IF diff$ = "P" THEN speed = speed - 10: curSpeed = speed
  511.                     END IF
  512.                     nonum = TRUE
  513.                     IF curSpeed < 1 THEN curSpeed = 1
  514.                 END IF
  515.             NEXT a
  516.  
  517.             FOR a = 1 TO NumPlayers
  518.                 'If player runs into any point, or the head of the other snake, it dies.
  519.                 IF PointIsThere(sammy(a).row, sammy(a).col, colorTable(4)) OR (sammy(1).row = sammy(2).row AND sammy(1).col = sammy(2).col) THEN
  520.                     PLAY "MBO0L32EFGEFDC"
  521.                     COLOR , colorTable(4)
  522.                     LOCATE numberRow, NumberCol
  523.                     PRINT " "
  524.                    
  525.                     playerDied = TRUE
  526.                     sammy(a).alive = FALSE
  527.                     sammy(a).lives = sammy(a).lives - 1
  528.  
  529.                 'Otherwise, move the snake, and erase the tail
  530.                 ELSE
  531.                     sammy(a).head = (sammy(a).head + 1) MOD MAXSNAKELENGTH
  532.                     sammyBody(sammy(a).head, a).row = sammy(a).row
  533.                     sammyBody(sammy(a).head, a).col = sammy(a).col
  534.                     tail = (sammy(a).head + MAXSNAKELENGTH - sammy(a).length) MOD MAXSNAKELENGTH
  535.                     Set sammyBody(tail, a).row, sammyBody(tail, a).col, colorTable(4)
  536.                     sammyBody(tail, a).row = 0
  537.                     Set sammy(a).row, sammy(a).col, sammy(a).scolor
  538.                 END IF
  539.             NEXT a
  540.  
  541.         LOOP UNTIL playerDied
  542.  
  543.         curSpeed = speed                ' reset speed to initial value
  544.        
  545.         FOR a = 1 TO NumPlayers
  546.             EraseSnake sammy(), sammyBody(), a
  547.  
  548.             'If dead, then erase snake in really cool way
  549.             IF sammy(a).alive = FALSE THEN
  550.                 'Update score
  551.                 sammy(a).score = sammy(a).score - 10
  552.                 PrintScore NumPlayers, sammy(1).score, sammy(2).score, sammy(1).lives, sammy(2).lives
  553.                 
  554.                 IF a = 1 THEN
  555.                     SpacePause " Sammy Dies! Push Space! --->"
  556.                 ELSE
  557.                     SpacePause " <---- Jake Dies! Push Space "
  558.                 END IF
  559.             END IF
  560.         NEXT a
  561.  
  562.         Level SAMELEVEL, sammy()
  563.         PrintScore NumPlayers, sammy(1).score, sammy(2).score, sammy(1).lives, sammy(2).lives
  564.      
  565.     'Play next round, until either of snake's lives have run out.
  566.     LOOP UNTIL sammy(1).lives = 0 OR sammy(2).lives = 0
  567.  
  568. END SUB
  569.  
  570. 'PointIsThere:
  571. '  Checks the global  arena array to see if the boolean flag is set
  572. FUNCTION PointIsThere (row, col, acolor)
  573.     IF row <> 0 THEN
  574.         IF arena(row, col).acolor <> acolor THEN
  575.             PointIsThere = TRUE
  576.         ELSE
  577.             PointIsThere = FALSE
  578.         END IF
  579.     END IF
  580. END FUNCTION
  581.  
  582. 'PrintScore:
  583. '  Prints players scores and number of lives remaining
  584. SUB PrintScore (NumPlayers, score1, score2, lives1, lives2)
  585.     COLOR 15, colorTable(4)
  586.  
  587.     IF NumPlayers = 2 THEN
  588.         LOCATE 1, 1
  589.         PRINT USING "#,###,#00  Lives: #  <--JAKE"; score2; lives2
  590.     END IF
  591.  
  592.     LOCATE 1, 49
  593.     PRINT USING "SAMMY-->  Lives: #     #,###,#00"; lives1; score1
  594. END SUB
  595.  
  596. 'Set:
  597. '  Sets row and column on playing field to given color to facilitate moving
  598. '  of snakes around the field.
  599. SUB Set (row, col, acolor)
  600.     IF row <> 0 THEN
  601.         arena(row, col).acolor = acolor             'assign color to arena
  602.         realRow = arena(row, col).realRow           'Get real row of pixel
  603.         topFlag = arena(row, col).sister + 1 / 2    'Deduce whether pixel
  604.                                                     'is on top▀, or bottom▄
  605.         sisterRow = row + arena(row, col).sister    'Get arena row of sister
  606.         sisterColor = arena(sisterRow, col).acolor  'Determine sister's color
  607.  
  608.         LOCATE realRow, col
  609.  
  610.         IF acolor = sisterColor THEN                'If both points are same
  611.             COLOR acolor, acolor                           'Print chr$(219) "█"
  612.             PRINT CHR$(219);
  613.         ELSE
  614.             IF topFlag THEN                         'Since you cannot have
  615.                 IF acolor > 7 THEN                  'bright backgrounds
  616.                     COLOR acolor, sisterColor       'determine best combo
  617.                     PRINT CHR$(223);                'to use.
  618.                 ELSE
  619.                     COLOR sisterColor, acolor
  620.                     PRINT CHR$(220);
  621.                 END IF
  622.             ELSE
  623.                 IF acolor > 7 THEN
  624.                     COLOR acolor, sisterColor
  625.                     PRINT CHR$(220);
  626.                 ELSE
  627.                     COLOR sisterColor, acolor
  628.                     PRINT CHR$(223);
  629.                 END IF
  630.             END IF
  631.         END IF
  632.     END IF
  633. END SUB
  634.  
  635. 'SpacePause:
  636. '  Pauses game play and waits for space bar to be pressed before continuing
  637. SUB SpacePause (text$)
  638.  
  639.     COLOR colorTable(5), colorTable(6)
  640.     Center 11, "█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█"
  641.     Center 12, "█ " + LEFT$(text$ + SPACE$(29), 29) + " █"
  642.     Center 13, "█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█"
  643.     WHILE INKEY$ <> "": WEND
  644.     WHILE INKEY$ <> " ": WEND
  645.     COLOR 15, colorTable(4)
  646.  
  647.     FOR i = 21 TO 26            ' Restore the screen background
  648.         FOR j = 24 TO 56
  649.             Set i, j, arena(i, j).acolor
  650.         NEXT j
  651.     NEXT i
  652.  
  653. END SUB
  654.  
  655. 'SparklePause:
  656. '  Creates flashing border for intro screen
  657. SUB SparklePause
  658.  
  659.     COLOR 4, 0
  660.     a$ = "*    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    "
  661.     WHILE INKEY$ <> "": WEND 'Clear keyboard buffer
  662.  
  663.     WHILE INKEY$ = ""
  664.         FOR a = 1 TO 5
  665.             LOCATE 1, 1                             'print horizontal sparkles
  666.             PRINT MID$(a$, a, 80);
  667.             LOCATE 22, 1
  668.             PRINT MID$(a$, 6 - a, 80);
  669.  
  670.             FOR b = 2 TO 21                         'Print Vertical sparkles
  671.                 c = (a + b) MOD 5
  672.                 IF c = 1 THEN
  673.                     LOCATE b, 80
  674.                     PRINT "*";
  675.                     LOCATE 23 - b, 1
  676.                     PRINT "*";
  677.                 ELSE
  678.                     LOCATE b, 80
  679.                     PRINT " ";
  680.                     LOCATE 23 - b, 1
  681.                     PRINT " ";
  682.                 END IF
  683.             NEXT b
  684.         NEXT a
  685.     WEND
  686.  
  687. END SUB
  688.  
  689. 'StillWantsToPlay:
  690. '  Determines if users want to play game again.
  691. FUNCTION StillWantsToPlay
  692.  
  693.     COLOR colorTable(5), colorTable(6)
  694.     Center 10, "█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█"
  695.     Center 11, "█       G A M E   O V E R       █"
  696.     Center 12, "█                               █"
  697.     Center 13, "█      Play Again?   (Y/N)      █"
  698.     Center 14, "█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█"
  699.  
  700.     WHILE INKEY$ <> "": WEND
  701.     DO
  702.         kbd$ = UCASE$(INKEY$)
  703.     LOOP UNTIL kbd$ = "Y" OR kbd$ = "N"
  704.  
  705.     COLOR 15, colorTable(4)
  706.     Center 10, "                                 "
  707.     Center 11, "                                 "
  708.     Center 12, "                                 "
  709.     Center 13, "                                 "
  710.     Center 14, "                                 "
  711.  
  712.     IF kbd$ = "Y" THEN
  713.         StillWantsToPlay = TRUE
  714.     ELSE
  715.         StillWantsToPlay = FALSE
  716.         COLOR 7, 0
  717.         CLS
  718.     END IF
  719.  
  720. END FUNCTION
  721.  
  722.